package com.example.JavaWebApi.core.htmlhelper;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: cms_zjgs_api
 * @description: html解析帮助类
 * @author: yang ze
 * @create: 2021-12-10 09:51
 */
public class HtmlParseHelper {
    public static List<String> getTagsContent(String Html,String TagName,String AttrbuteName){
        List<String> Content=new ArrayList<>();
        Document doc= Jsoup.parseBodyFragment(Html);
        Elements e=doc.getElementsByTag(TagName);
        Content=e.stream().map(t->t.attr(AttrbuteName)).collect(Collectors.toList());
        return Content;
    }
}